import com.hotel.mapper.RoleMapper;
import com.hotel.mapper.UserMapper;
import com.hotel.pojo.Role;
import com.hotel.pojo.Room;
import com.hotel.pojo.User;
import com.hotel.service.RoleService;
import com.hotel.service.RoomService;
import com.hotel.service.UserService;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class Mytest {
    @Test
    public void test(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userServiceImpl = (UserService) context.getBean("userServiceImpl");
        for (User user : userServiceImpl.getAll()) {
            System.out.println(user);
        }
    }

    @Test
    public void test1(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        RoleService roleServiceImpl = (RoleService) context.getBean("roleServiceImpl");
        for (Role user : roleServiceImpl.getAll()) {
            System.out.println(user);
        }
    }

    @Test
    public void test2(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        RoleMapper roleMapper = (RoleMapper) context.getBean("roleMapper");
        for (Role user : roleMapper.getAll()) {
            System.out.println(user);
        }
    }

    @Test
    public void test3(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserMapper userMapper = (UserMapper) context.getBean("userMapper");
        for (User user : userMapper.getAll()) {
            System.out.println(user);
        }
    }

    @Test
    public void test4(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        RoleMapper roleMapper = (RoleMapper) context.getBean("roleMapper");
        Role role = roleMapper.selectRoleById(2);
        System.out.println(role);
    }

    @Test
    public void test5(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        RoomService roomService = (RoomService)  context.getBean("roomServiceImpl");
        Room room = new Room();
        room.setRoomName("xxx");
        room.setRoomDesc("xxx");
        room.setStatus("n");
        roomService.addRoom(room);

    }

    @Test
    public void test6(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        RoomService roomService = (RoomService)  context.getBean("roomServiceImpl");
        List<Room> room = roomService.selectRoomByName("大床房");
        System.out.println(room);


    }

    @Test
    public void test7(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserMapper userMapper = (UserMapper)  context.getBean("userMapper");
        userMapper.getAll();


    }
    @Test
    public void test8(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userService = (UserService)  context.getBean("userServiceImpl");
        List<User> all = userService.getAll();
        System.out.println(all);


    }
}
